package com.haoshuang.zhouzhoubang.ui.page.shop.order.child

import androidx.lifecycle.rxLifeScope
import com.haoshuang.zhouzhoubang.base.request
import com.haoshuang.zhouzhoubang.model.bean.OrderBean8
import com.mufeng.libs.base.BaseViewModel
import com.mufeng.libs.state.StateData
import com.mufeng.libs.state.StatefulMutableLiveData

class OrderListShopViewModel : BaseViewModel() {
    val getData2 = StatefulMutableLiveData<Any>()
    fun getData2(vararg params: Pair<String, Any?>) {
        rxLifeScope.launch {
            request<Any>("api/user/cancel_shop_order", *params,
                onStart = {
                    getData2.value = StateData.Loading
                },
                onError = { msg, code ->
                    getData2.value = StateData.Error(code, msg)
                }, onSuccess = {
                    getData2.value = StateData.Success(it)
                })
        }
    }
    val getData3 = StatefulMutableLiveData<Any>()
    fun getData3(vararg params: Pair<String, Any?>) {
        rxLifeScope.launch {
            request<Any>("api/user/user_take_order", *params,
                onStart = {
                    getData3.value = StateData.Loading
                },
                onError = { msg, code ->
                    getData3.value = StateData.Error(code, msg)
                }, onSuccess = {
                    getData3.value = StateData.Success(it)
                })
        }
    }

    val getData = StatefulMutableLiveData<ArrayList<OrderBean8>>()
    fun getData(vararg params: Pair<String, Any?>) {
        rxLifeScope.launch {
            request<ArrayList<OrderBean8>>("api/user/get_user_shop_order_list", *params,
                onStart = {
                    getData.value = StateData.Loading
                },
                onError = { msg, code ->
                    getData.value = StateData.Error(code, msg)
                }, onSuccess = {
                    getData.value = StateData.Success(it)
                })
        }
    }
}